<?php
$this->pageTitle=Yii::app()->name . ' - Svn Commit';
$this->breadcrumbs=array(
	'Svn update&commit',
);
?>
<?php $this->widget('bootstrap.widgets.TbButton', array(
    'buttonType'=>'button',
    'type'=>'primary',
    'label'=>'ReloadCacheFromFile',
    'loadingText'=>'loading...',
    'htmlOptions'=>array('id'=>'reload'),
)); ?>
<br>
<br>
<?php $this->widget('bootstrap.widgets.TbButton', array(
    'buttonType'=>'button',
    'type'=>'primary',
    'label'=>'RewriteCacheToFile',
    'loadingText'=>'writing...',
    'htmlOptions'=>array('id'=>'rewrite'),
)); ?>
(not implemented)
<br>
<div class="alert alert-info" id="retFailedVal" style="display: none; ">
</div>
<div class="alert success-info" id="retSuccessVal" style="display: none; ">
</div>
<?php Yii::app()->clientScript->registerScript('function',
'

$("#reload").click(function() {
	$("#retFailedVal").hide();
	$("#retSuccessVal").hide();
    var btn = $(this);
    btn.button("loading"); // call the loading function
    $.post("'.Yii::app()->createUrl('site/reload').'",function(data){
    		if(data["ret"] == 0)
    		{
    			$("#retFailedVal").show();
    			$("#retFailedVal").html(data["info"]);
    		}
    		else
    		{
    			$("#retSuccessVal").show();
    			$("#retSuccessVal").html(data["info"]);
    		}
		btn.button("reset");
    		},"json");
});
$("#rewrite").click(function() {
    var btn = $(this);
    btn.button("loading"); // call the loading function
    $.post("'.Yii::app()->createUrl('site/rewrite').'")
    setTimeout(function() {
        btn.button("reset"); // call the reset function
    }, 10000);
});'
);
?>
<script>

</script>
please UPDATE before COMMIT
<br>
<?php if(isset($ret)) ?>
<?php echo count($ret['old'])." files not sync, database version older than filesystem. ";?>
<?php if(count($ret['old']) > 0) echo "PERFORM RELOAD!!!"; ?>
<div class="alert alert-error" id="olddblist">
<?php foreach ($ret['old'] as $old) {
	echo $old->category."<br>";
}?>
</div>
<? endif ?>
<br>
<?php echo count($ret['new'])." files not sync, database version newer than filesystem";?>
<div class="alert alert-error" id="newdblist">
<?php foreach ($ret['new'] as $new) {
	echo $new->category."<br>";
}?>
</div>
<?php 
Yii::app()->clientScript->registerScript('onSvnUpdate',
'
		$("#updateBut").click(function(){
		$.get("'.Yii::app()->createUrl("site/svnupdate").'",function(result)
		{
			$(".flash-success").html(result);
		}
		
		)
		});
'
)
?>

<h1>Svn</h1>
 <?php
 // $this->widget('bootstrap.widgets.TbButton', array(
//     'label'=>'Svn Update',
//     'type'=>'primary', // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
//     'size'=>'', // '', 'large', 'small' or 'mini'
//     'htmlOptions'=>array('id'=>'updateBut'),
// )); ?>
<?php if(Yii::app()->user->hasFlash('svncommit')): ?>

<div class="flash-success">
	<?php echo Yii::app()->user->getFlash('svncommit'); ?>
</div>

<?php else: ?>

<?php endif; ?>
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'id'=>'commit-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="help-block">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<?php echo $form->textFieldRow($model,'svnname',array('class'=>'span5','maxlength'=>30)); ?>

	<?php echo $form->passwordFieldRow($model,'svnpass',array('maxlength'=>30, 'class'=>'span5')); ?>

	<?php echo $form->textAreaRow($model,'comment',array('rows'=>6, 'cols'=>50, 'class'=>'span8')); ?>
	<br>
	<?php echo $form->dropDownList($model,'action',(array("commit","update")))?>
	<div class="form-actions">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
			'label'=>'Submit',
		)); ?>
	</div>

<?php $this->endWidget(); ?>
